package com.qiaoyanqing.textdemoqyq7.Beans;

import android.util.Log;

import com.qiaoyanqing.textdemoqyq7.Adapters.BannerAdapter;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/14.
 */

public class ViewpagerBean {

    private String image;
    private String title;

    @Override
    public String toString() {
        return "ViewpagerBean{" +
                "image='" + image + '\'' +
                ", title='" + title + '\'' +
                '}';
    }
    public static ViewpagerBean parseJson(String data){

        List<ViewpagerBean> list=new ArrayList<>();
        try {
            JSONObject jsonObject=new JSONObject(data);
            JSONArray jsonArray=jsonObject.optJSONArray("data");

            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonObject1=jsonArray.optJSONObject(i);
                ViewpagerBean viewpagerBean=new ViewpagerBean();
                viewpagerBean.setImage(jsonObject1.optString("image"));
                viewpagerBean.setTitle(jsonObject1.optString("title"));
                list.add(viewpagerBean);
            }
            Log.d("flag", " Viewpager parseJson: "+list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return (ViewpagerBean) list;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
